package com.seewintech.framework.controller;

import com.seewintech.framework.command.UserLoginCommand;
import com.seewintech.framework.common.http.Result;
import com.seewintech.framework.common.success.AjaxResult;
import com.seewintech.framework.service.UserTokenService;
import com.seewintech.framework.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author by xiaoTian
 * @date 2022/6/15.
 */
@RestController
@RequestMapping("/token")
public class UserTokenController {

    @Autowired
    UserTokenService userTokenService;


    // login
    @PostMapping("/login")
    public Result login(@RequestBody UserLoginCommand command){
        UserVo loginUser = userTokenService.login(command.getName(),command.getPassword());
        return Result.success(loginUser);
    }


    // register
    @PostMapping("/register")
    public Result register(@RequestBody UserLoginCommand command){
        return Result.ajaxResult(
                new AjaxResult(userTokenService.register(command.getName(),command.getPassword())));
    }












}
